﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _06FirstBiggerThanNeighbor
{
    class Program
    {
        static bool BiggerThanNeighbor(int[] array, int i)
        {
            bool isBigger = false;
            if ((i > 0) && (i < array.Length - 1))
            {
                if ((array[i] > array[i - 1]) && (array[i] > array[i + 1]))
                {
                    isBigger = true;
                }
            }
            if (i == 0)
            {
                if (array[i] > array[i + 1])
                {
                    isBigger = true;
                }
            }
            if (i == (array.Length - 1))
            {
                if (array[i] > array[i - 1])
                {
                    isBigger = true;
                }
            }
            return isBigger;
        }
        static int FirstBiggerElement(int[] array)
        {
            int element = -1;
            for (int i = 0; i < array.Length; i++)
            {
                if (BiggerThanNeighbor(array, i))
                {
                    element = i;
                    break;
                }
            }
            return element;
        }
        static void Main(string[] args)
        {
            Console.Write("Array size:");
            int arraySize = int.Parse(Console.ReadLine());
            int[] array = new int[arraySize];
            for (int i = 0; i < array.Length; i++)
            {
                Console.Write("array[{0}]:", i);
                array[i] = int.Parse(Console.ReadLine());
            }
            Console.Write("The first element that is bigger than its neighbors is at position:" + FirstBiggerElement(array));
            Console.WriteLine();
        }
    }
}
